<template>
  <div class="home" style="height: 100%">
    <el-container style="height: 100%" direction="vertical">
      <el-header style="background-color: rgb(87, 97, 137)">
        <div class="header">
          <span class="proTitle">论坛后台管理系统</span>
          <div class = "userNick">  {{ userNick }}  </div>
          <el-dropdown class="logout">
            
            <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"/>  
              <el-icon class="el-icon--right">
                <arrow-down />
              </el-icon>
            
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>个人信息</el-dropdown-item>

                <el-dropdown-item @click="logout()">退出登录</el-dropdown-item>

              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px" style="background-color: #545c64">
          <el-menu
            active-text-color="#ffd04b"
            background-color="#545c64"
            class="el-menu-vertical-demo"
            default-active="2"
            text-color="#fff"
            @open="handleOpen"
            @close="handleClose"
            :router="true"
          >
            <el-sub-menu index="1">
              <template #title>
                <el-icon><location /></el-icon>
                <span>人员管理</span>
              </template>
              <el-menu-item index="/user">用户管理</el-menu-item>
              <el-menu-item index="/role">角色管理</el-menu-item>
            </el-sub-menu>
          </el-menu>
        </el-aside>

        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import request from "@/utils/request";
import router from '@/router'
import store from "@/store";
import { ElMessage } from 'element-plus'
export default {
  data() {
    return {
        userNick: localStorage.getItem("userNick")

    };
  },
  created(){
   
  },
  methods: {
    logout(){
      this.$store.commit('LOGOUT')
      this.$router.push("/Login")
    }
  },
  compute:{
    userNick: function(){
      return store.state.userNick;
    }

  }
};
</script>
<style>
.header {
  margin-top: 10px;
  text-align: center;
  display: flex;
  position: relative;
}
.header .proTitle {
  font-family: "楷体", "宋体", serif;
  font-size: 40px;
}
.proTitle {
  margin-left: 40%;
}
.logout {
  margin-left: auto;
}
.el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
  font-size: 15px;
}
.userNick{
  display: inline-block;
  text-align: right;
  
  justify-content: flex-end;
  margin-top: 8px;
  width: 560px;
}
</style>
